home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_015 / fish / init.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  224 lines

  1. #include "fishes.h"
  2. #include <stdio.h>
  3.  
  4. #define DEPTH 3 
  5. #define ALLSTART 0
  6. #define TEST
  7.  
  8.  
  9. extern short color[8];
  10. extern short color1[8];
  11. extern short color2[8];
  12.  
  13. short color92[] = {
  14. 0x28f,
  15. 0xffc,
  16. 0xfbf,
  17. 0xfd0,
  18. 0xf30,
  19. 0x90d,
  20. 0xff,
  21. 0xd9,
  22. };
  23.  
  24. extern struct AnimOb fishOb;
  25. extern struct Bob fish1Bob;
  26. extern struct AnimComp fish1Comp;
  27.  
  28. extern struct GelsInfo *GInfo;
  29. extern struct VSprite *head, *tail;
  30. extern struct collTable *boom;
  31.  
  32. SHORT timers[] =
  33. {
  34. /* fish's */
  35.     1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1, 1, 1, 1, 1,
  36. };
  37.  
  38. SHORT Index = 0;
  39.  
  40. SHORT xtranslations[] = 
  41. {
  42. /* fish's */
  43.     0 << ANFRACSIZE,
  44.     0 << ANFRACSIZE,
  45.     0 << ANFRACSIZE,
  46.     0 << ANFRACSIZE,
  47.     0 << ANFRACSIZE,
  48.     0 << ANFRACSIZE,
  49.     0 << ANFRACSIZE,
  50.     0 << ANFRACSIZE,
  51.     0 << ANFRACSIZE,
  52.     0 << ANFRACSIZE,
  53.     0 << ANFRACSIZE,
  54.     0 << ANFRACSIZE,
  55.     0 << ANFRACSIZE,
  56.     0 << ANFRACSIZE,
  57.     0 << ANFRACSIZE,
  58.     0 << ANFRACSIZE,
  59.     0 << ANFRACSIZE,
  60. };
  61.  
  62. SHORT ytranslations[] = 
  63. {
  64. /* fish's */
  65.     0 << ANFRACSIZE,
  66.     0 << ANFRACSIZE,
  67.     0 << ANFRACSIZE,
  68.     0 << ANFRACSIZE,
  69.     0 << ANFRACSIZE,
  70.     0 << ANFRACSIZE,
  71.     0 << ANFRACSIZE,
  72.     0 << ANFRACSIZE,
  73.     0 << ANFRACSIZE,
  74.     0 << ANFRACSIZE,
  75.     0 << ANFRACSIZE,
  76.     0 << ANFRACSIZE,
  77.     0 << ANFRACSIZE,
  78.     0 << ANFRACSIZE,
  79.     0 << ANFRACSIZE,
  80.     0 << ANFRACSIZE,
  81.     0 << ANFRACSIZE,
  82. };
  83.  
  84. SHORT XVel[] = 
  85. {
  86. /* fish's */
  87.     4 << ANFRACSIZE,
  88. };
  89.  
  90. SHORT YVel[] = 
  91. {
  92. /* fish's */
  93.     0 << ANFRACSIZE,
  94. };
  95.  
  96. /* !!! define an animCRoutine here */
  97.  
  98. /* !!! define an animORoutine here */
  99.  
  100. fishMRoutine(anOb)
  101. struct AnimOb *anOb;
  102. {
  103.     register struct AnimComp *acptr, *seqptr;
  104.  
  105.     acptr = anOb->HeadComp;
  106.     while (acptr)
  107.         {
  108.         seqptr = acptr;
  109.         do
  110.             {
  111.             if (seqptr->AnimBob->BobVSprite->Flags & GELGONE)
  112.                 {
  113.                 seqptr->AnimBob->BobVSprite->Flags &= ~GELGONE;
  114.                 fishOb.AnX = 0 << ANFRACSIZE;
  115.                 }
  116.             seqptr = seqptr->NextSeq;
  117.             }
  118.         while (seqptr != acptr && (seqptr));
  119.         acptr = acptr->NextComp;
  120.         }
  121. }
  122.  
  123. fish1Routine(comp)
  124. struct AnimComp *comp;
  125. {
  126.     /* if (fish1Comp.Timer == 1)
  127.         fishOb.AnX += (87 << ANFRACSIZE); */
  128.  
  129.     return(TRUE);
  130. }
  131.  
  132. short startFlag = 4;
  133.  
  134. animinit(animKey,vp, wR)
  135. struct AnimOb **animKey;
  136. struct ViewPort *vp;
  137. struct RastPort *wR;
  138. {
  139.     SHORT i;
  140.  
  141.     Index = 0;
  142.     fishOb.XVel = XVel[0];
  143.     fishOb.YVel = YVel[0];
  144.  
  145.     fishOb.HeadComp = &fish1Comp;
  146.  
  147.     fish1Bob.Before = NULL;
  148.     fish1Bob.After = NULL;
  149.  
  150.     InitAnimate(animKey);
  151.  
  152.     extrainit(&fishOb, TRUE, wR);   
  153.     AddAnimOb(&fishOb, animKey,wR);
  154.  
  155.     for (i = 0; i < 8; i++)
  156.         SetRGB4(vp,i ,
  157.             (color92[i] >> 8) & 0x00F, 
  158.             (color92[i] >> 4) & 0x00F, 
  159.             (color92[i] >> 0) & 0x00F); 
  160.     
  161. }
  162.  
  163. extrainit(animKey, addFlag,wR)
  164. struct AnimOb *animKey;
  165. BOOL addFlag;
  166. struct RastPort *wR;
  167. {
  168.     struct AnimOb *anOb;
  169.     struct AnimComp *acptr;
  170.     struct AnimComp *seqptr, *sseqptr;
  171.     struct Bob *bptr;
  172.     struct Sprite *sptr;
  173.     short i, depth, sw, sh;
  174.     UBYTE *iptr, *i2ptr, *pptr;
  175.     short ibufsize, pbufsize;
  176.  
  177.  
  178. /* animOb inits */
  179.  
  180.     anOb = animKey;
  181.     anOb->AnX = ALLSTART << ANFRACSIZE;
  182.     anOb->AnY = 0;
  183.  
  184.     anOb->XAccel = 0;
  185.     anOb->YAccel = 0;
  186.     anOb->Clock = 0;
  187.  
  188.     acptr = anOb->HeadComp;
  189.     while (acptr)
  190.         {
  191.         acptr->AnimBob->BobVSprite->X =
  192.         (anOb->AnX + xtranslations[Index] + ANIMHALF) >> ANFRACSIZE;
  193.         acptr->AnimBob->BobVSprite->Y =
  194.         (anOb->AnY + ytranslations[Index] + ANIMHALF) >> ANFRACSIZE;
  195.         sseqptr = seqptr = acptr;
  196.         do
  197.             {
  198.             seqptr->AnimBob->Flags = BOBISCOMP;
  199.             seqptr->AnimBob->BobVSprite->Flags = SAVEBACK|OVERLAY;
  200.             seqptr->TimeSet = timers[Index];
  201.             seqptr->XTrans = xtranslations[Index];
  202.             seqptr->YTrans = ytranslations[Index];
  203.             seqptr->AnimBob->BobVSprite->PlaneOnOff= 0x10;
  204.             Index++;
  205.             seqptr = seqptr->NextSeq;
  206.             }
  207.         while (seqptr != sseqptr && (seqptr));
  208.         acptr = acptr->NextComp;
  209.         }
  210.  
  211.     if (! (GetGBuffers(anOb, wR, TRUE)))
  212.     {  
  213.         exit(3);
  214.     }
  215.     InitGMasks(anOb);
  216. }
  217.  
  218. free_anim_obj(RPort)
  219. struct RastPort *RPort;
  220. {
  221.  
  222.     FreeGBuffers(&fishOb,RPort,TRUE);
  223.